package com.iTextDemo;

import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Element;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

public class CreateParagraph {
    public static void main(String[] args) throws IOException, DocumentException {
        Document document = new Document();
        PdfWriter.getInstance(document, Files.newOutputStream(Paths.get("C:\\Users\\wy\\Desktop\\1\\iTextParagraph3.pdf")));
        document.open();
        Paragraph paragraph = new Paragraph("This paragraph will be horizontally centered.");
        paragraph.setAlignment(Element.ALIGN_CENTER);
        document.add(paragraph);
        document.close();
    }
}
